package org.swingplus.core.factory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.swingplus.core.bean.RootBeanDefinition;
import org.swingplus.core.scanner.BindScan;

import java.lang.reflect.Constructor;
import java.lang.reflect.Parameter;

public class ConstructorAutowiredFactory extends AbstractAutowireBeanFactory {


    private static final Logger logger = LoggerFactory.getLogger(ConstructorAutowiredFactory.class);

    public static void getBean(Class clazz, RootBeanDefinition rootBeanDefinition) {

        Constructor[] constructors = clazz.getConstructors();

        for (Constructor con : constructors) {

            Class[] parameterTypes = con.getParameterTypes();
            for (Class parameterType : parameterTypes) {
                System.out.println(parameterType.getTypeName());
            }

            for (Class parameterType : parameterTypes) {
                System.out.println(parameterType.getTypeName());
//                parameterType.cast()
            }
//            con.
            int parameterCount=con.getParameterCount();

            System.out.println(parameterCount);


            Parameter[] parameters = con.getParameters();
            for (Parameter parameter :
                    parameters) {
                System.out.println(parameter.getName());
                System.out.println(parameter.getType().getName());
            }

//            con.newInstance("xiaoxiao",21);

        }


        return;
    }

    public static void main(String[] args) {
        getBean(BindScan.class,null);
    }

}
